package timing.ukulele.flow.vo;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.activiti.engine.impl.persistence.entity.HistoricVariableInstanceEntityImpl;
import org.activiti.engine.impl.persistence.entity.VariableInstanceEntityImpl;
import org.activiti.engine.task.DelegationState;

import java.io.Serializable;
import java.util.Date;
import java.util.List;
import java.util.Map;

@Data
@ApiModel("任务")
public class TaskVO implements Serializable, Comparable<TaskVO>{
    @ApiModelProperty("任务id")
    private String id;
    @ApiModelProperty("任务类型: 0待办任务  1已办任务")
    private Integer taskType;
    @ApiModelProperty("任务的办理人")
    private String taskAssignee;
    @ApiModelProperty("流程实例ID")
    private String processInstanceId;
    @ApiModelProperty("执行对象ID")
    private String executionId;
    @ApiModelProperty("流程定义ID")
    private String processDefinitionId;
    @ApiModelProperty("流程表单")
    private String formKey;

    @ApiModelProperty("任务拥有者")
    private String owner;
    @ApiModelProperty("执行人更改次数")
    private int assigneeUpdatedCount;
    @ApiModelProperty("原始执行人")
    private String originalAssignee;
    @ApiModelProperty("实际执行人")
    private String assignee;
    @ApiModelProperty("候选人")
    private String candidate;
    private DelegationState delegationState;
    private String parentTaskId;
    @ApiModelProperty("任务名称")
    private String name;
    private String localizedName;
    @ApiModelProperty("任务描述")
    private String description;
    private String localizedDescription;
    @ApiModelProperty("流程实例创建时间")
    private Date procinstCreateTime;
    @ApiModelProperty("任务创建时间")
    private Date createTime;
    @ApiModelProperty("任务转接时间")
    private Date claimTime;
    @ApiModelProperty("任务结束时间")
    private Date endTime;
    private Date dueDate;
    private String eventName;
    @ApiModelProperty("租户系统id")
    private String tenantId;
    @ApiModelProperty("任务指定人类型 0配置 1前端指定 2同前一个节点一样")
    private String assigneeType;
    @ApiModelProperty("任务配置时的人员集合")
    private String configureUsers;
    @ApiModelProperty("任务锁状态")
    private Boolean locked;

    @ApiModelProperty("节点自定义参数")
    private Map<String, String> properties;
    @ApiModelProperty("待办任务变量")
    private List<VariableInstanceEntityImpl> runningVariables;
    @ApiModelProperty("历史任务变量")
    private List<HistoricVariableInstanceEntityImpl> historyVariables;

    @Override
    public int compareTo(TaskVO o) {
        if (this.createTime.compareTo(o.getCreateTime()) > 0) {
            return 1;
        } else if (this.createTime.compareTo(o.getCreateTime()) == 0) {
            return 0;
        } else {
            return -1;
        }
    }
}
